<template>
	<view>
		<view class=" content">
			<image class="logo" :src="logo" mode=""></image>
	
		<!-- 	<uv-input :customStyle="custom" placeholderClass="placeholderClass" class="inputbox" placeholder="请输入账号"
				:border="none" v-model="username">
				<template v-slot:prefix>
					<image style="width: 35rpx;margin-right: 10rpx;height: auto;" src="/static/images/1.png" mode="widthFix"></image>
				</template>
			</uv-input> -->
			<uv-input :customStyle="custom" placeholderClass="placeholderClass" class="inputbox" placeholder="请输入手机号码"
				:border="none" v-model="mobile">

				<template v-slot:prefix>
					<image style="width: 35rpx;margin-right: 10rpx;height: 35rpx;" src="/static/images/2.png" mode="widthFix"></image>
				</template>
			</uv-input>
			<uv-input :customStyle="custom" placeholderClass="placeholderClass" class="" placeholder="请输入验证码"
				:border="none" v-model="code">

				<template v-slot:prefix>
					<image style="width: 35rpx;margin-right: 10rpx;height: 35rpx;" src="/static/images/4.png" mode="widthFix"></image>
				</template>
				<template v-slot:suffix>
					<text class="getcode" @click="getCode()" style="">{{timer?timer+'s后可重新获取': '获取验证码'}}</text>
				</template>
			</uv-input>
			<uv-input :customStyle="custom" type="password" placeholderClass="placeholderClass" class="inputbox"
				placeholder="请输入新密码" :border="none" v-model="password">

				<template v-slot:prefix>
					<image style="width: 35rpx;margin-right: 10rpx;height: 35rpx;" src="/static/images/3.png" mode="widthFix"></image>
				</template>
			</uv-input>
			<uv-input :customStyle="custom" type="password" placeholderClass="placeholderClass" class="inputbox"
				placeholder="请再次输入新密码" :border="none" v-model="password2">

				<template v-slot:prefix>
					<image style="width: 35rpx;margin-right: 10rpx;height: 35rpx;" src="/static/images/3.png" mode="widthFix"></image>
				</template>
			</uv-input>
			<button class="submit" @click="register">提交</button>
		</view>
		
	</view>
</template>

<script>
	import operate from '@/common/operate.js'
	export default {
		data() {
			return {
				account: "",
				custom: {
					'width': '630rpx',
					'height': '86rpx',
					'background': '#F5F5F5',
					'border-radius': '43rpx',
					'padding-left': '40rpx',
					'margin': " 0 auto 30rpx"
				},
				checked: [],
				placeholderStyle: {

				},
				roledata: [],
				password: "",
				password2: "",
				email: "",
				mobile: "",
				roleName: "",
				jiaose_id: "",
				username: "",
				logo:"",
				timer:0,
				code:""
			}
		},
		onLoad() {
			this.$api.config().then(res=>{
				console.log(res)
				this.logo = res.data.logo
			})
			this.getUserRole()
			// this.getSessionKey()  
		},
		mounted() {
			// this.$refs.popup.open()
		},
		methods: {
			getUserRole() {
				this.$api.userRole().then(res => {
					this.roledata = [res.data]
				})
			},
			roleConfirm(data) {
				console.log(data)
				this.roleName = data.value[0].name
				this.jiaose_id = data.value[0].id
			},
			showpicker() {
				this.$refs.rolePicker.open()
			},


			changeCheck(val) {
				this.checked = val
			},

			toxy(type) {
				uni.navigateTo({
					url: '/pages/about/index?type=' + type
				})
			},
			getCode(){
				if (!this.mobile) return this.$utils.msg('请输入手机号码')
				if(this.timer>0)return
				let vm =this
				this.$api.getauthsmsvcode({mobile:this.mobile}).then(res=>{
					if (res.code == 1) {
						vm.$utils.msg('发送成功')
						vm.countDown()
					}
						
				})
			},
			countDown(){
					this.timer = 60
						
					let setTimer = setInterval(()=>{
						this.timer--
						if(this.timer==0){
							clearInterval(setTimer)
						}
					},1000)
			},
			register() {
				
				// if (!this.username) return this.$utils.msg('请输入账号')
				if (!this.mobile) return this.$utils.msg('请输入手机号码')
				if (!this.$utils.checkStr(this.mobile, 'mobile')) return this.$utils.msg('请输入正确的手机号码')
				if (!this.password) return this.$utils.msg('请输入新密码')
				if(!this.code)return this.$utils.msg('请输入验证码')
				if (! (this.password == this.password2)) return this.$utils.msg('两次密码输入不一致请重新输入')
				this.$api.resetpwd({
					// username: this.username,
					type: 'mobile',
					mobile: this.mobile,
					captcha:this.code,
					newpassword: this.password,
					
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						
						
						uni.showToast({
							title: '修改成功',
							duration: 1500,
							complete: function() {

							}
						})
						setTimeout(()=>{
							uni.navigateBack()
						},1000)
							
					} else {
						this.$utils.msg(res.msg)
					}
				})
			},
			getUserSf() {
				this.$api.userGroup().then(res => {
					console.log(res)
						
					switch (res.data.jiaose_id){
							case "2":
							uni.reLaunch({
									url:'/pages/storeApply/index'
								})
							
							break;
							case "1":
							uni.reLaunch({
									url:'/pages/whUserApply/index'
								})
							
							break;
							case "0":
							uni.switchTab({
									url:'/pages/tabbar/index'
								})
							
							break;
						
						
					}
					// 	case "0":
					// 	if(res.data.shiming_status=='2'){
					// 		uni.switchTab({
					// 			url:'/pages/tabbar/index'
					// 		})
					// 	}else{
					// 		uni.redirectTo({
					// 			url:'/pages/artApply/index'
					// 		})
					// 	}
					// 	break;
					// 	case "1":
					// 	if(res.data.wanghong_status=='2'){
					// 		uni.switchTab({
					// 			url:'/pages/tabbar/index'
					// 		})
					// 	}else{
					// 		uni.redirectTo({
					// 			url:'/pages/whUserApply/index'
					// 		})
					// 	}
					// 	break;
					// 	case "2":
					// 	if(res.data.gys_status=='2'){
							
					// 	}else{
					// 		uni.redirectTo({
					// 			url:'/pages/storeApply/index'
					// 		})
					// 	}
					// 	break;
					// }
					
					
				})
			}



		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

.logo {
		width: 241rpx;
		display: block;
		height: 90rpx;
		margin: 116rpx auto 110rpx;
	}

	.content {
		

	}

	.avatar-box {
		width: 96rpx;
		height: 96rpx;
		background: transparent;
		border: none;
		border-radius: 50%;

		image {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}

		&::after {
			display: none;
		}
	}

	.title {
		font-size: 32rpx;
		text-align: center;
		margin: 30rpx auto 60rpx;
		font-weight: 600;
	}

	.submit {
		width: 630rpx;
		height: 90rpx;
		background: #49806F;
		border-radius: 45rpx;
		margin: 60rpx auto 36rpx;
		font-weight: 500;

		font-size: 34rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 90rpx;
	}

	.inputbox {
		width: 630rpx;
		height: 86rpx;
		background: #F5F5F5;
		border-radius: 43rpx;

		image {
			width: 35rpx;
		}
	}

	/deep/.placeholderClass {
		font-size: 30rpx;
		color: #B5BABF
	}

	.register {
		font-weight: 500;
		font-size: 34rpx;
		color: #999999;
		text-align: center;
	}

	.xy {

		position: fixed;
		bottom: 100rpx;
		left: 0;
		right: 0;
		margin: auto;

		text {}
	}

	.selectrole {
		width: 630rpx;
		height: 86rpx;
		background: #F5F5F5;
		border-radius: 43rpx;
		padding-left: 40rpx;
		margin: 0 auto 30rpx;
		font-size: 30rpx;
		color: #B5BABF;
		position: relative;

		view {
			position: absolute;
			right: 20rpx;
			top: 0;
			bottom: 0;
			margin: auto;
		}
	}

	/deep/.getcode {
		font-size: 30rpx;
		color: #B5BABF;
		margin-right: 30rpx;
		position: relative;
	}

	/deep/.getcode ::before {
		position: absolute;
		clear: both;
		content: '';
		left: -16rpx;
		background-color: #B5BABF;
		width: 1rpx;
		top: 0;
		bottom: 0;
		margin: auto;
		height: 33rpx;

	}

	.rolename {
		color: #333;
		padding-right: 60rpx;
	}
</style>